//
//  SISSNetworkingManager+Progress.m
//  SISSAPP
//
//  Created by 优房网 on 2017/7/7.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSNetworkingManager+Progress.h"

#import "SISSBuyerImportantNotiModel.h"
#import "SISSSellerImportantNotiModel.h"
#import "SISSIntermediaryContractModel.h"
#import "SISSBrokerInfoModel.h"
#import "SISSSellerInfoModel.h"
#import "SISSBuyerInfoModel.h"
#import "SISSTenancyContractModel.h"
#import "SISSRentOutModel.h"
#import "SISSTenantInfoModel.h"
#import "SISSNetworkingManager+File.h"
#import "SISSEntrustContractModel.h"
#import "SISSAdditionalNodeModel.h"
#import "SISSContractVerifyInfoModel.h"

@implementation SISSNetworkingManager (Progress)


// 4.16 追加评价
- (void)insertAdditionalCommentWithAcrId:(NSString *)acrId content:(NSString *)content commentType:(NSInteger)commentType success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                @"acrId":acrId,
                                @"content":content,
                                @"comment_type":@(commentType)
                                };
    
    [kNetworkManager POSTWithURLString:URL_PROGRESS_INSERT_ADDITIONAL_COMMENT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.16 追加评价%zd: responseObject-->%@",commentType,responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.24.1 更新进度委托合同 (图文上传) PUT请求
- (void)updateEntrustContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    if (images.count > 0) {
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSMutableArray *dataArrM = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"file":dataArrM,
                                            @"saId" : [SISSUserAccount shared].saId,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_ENTRUST_CONTRACT parameters:params success:^(id responseObject) {
                    NSLog(@"4.24.1 更新进度委托合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_ENTRUST_CONTRACT parameters:params success:^(id responseObject) {
            NSLog(@"4.24.1 更新进度委托合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
    
}

// 4.26.1 获取进度委托合同 GET请求
- (void)requestProgressEntrustContractWithAbpId:(NSString *)abpId success:(void (^)(SISSEntrustContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"abpId":abpId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_ENTRUST_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.26.1 获取进度委托合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSEntrustContractModel *entrustContractModel = [SISSEntrustContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(entrustContractModel);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.26.2.2 获取合同经纪人信息 GET请求
- (void)requestContractBrokerInfoWithSuccess:(void (^)(SISSBrokerInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
   
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_CONTRACT_BROKER_INFO parameters:parameters success:^(id responseObject) {
        NSLog(@"4.26.2.2 获取合同经纪人信息 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSBrokerInfoModel *brokerInfo = [SISSBrokerInfoModel yy_modelWithJSON:dataDict];
        
        if (successBlock) {
            successBlock(brokerInfo);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

- (void)requestContractBrokerInfoWithSpId:(NSString *)spId success:(void (^)(SISSBrokerInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":spId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_CONTRACT_BROKER_INFO parameters:parameters success:^(id responseObject) {
        NSLog(@"4.26.2.2 获取合同经纪人信息 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSBrokerInfoModel *brokerInfo = [SISSBrokerInfoModel yy_modelWithJSON:dataDict];
        
        if (successBlock) {
            successBlock(brokerInfo);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.27.1 获取进度买方重要事项告知书 GET请求
- (void)requestrProgressBuyerImportantNotiInfoWithParameters:(NSDictionary *)parameters success:(void (^)(SISSBuyerImportantNotiModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_BUYER_IMOPRTANT_NOTI parameters:parameters success:^(id responseObject) {
        NSLog(@"4.27.1 获取进度买方重要事项告知书 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSBuyerImportantNotiModel *model = [SISSBuyerImportantNotiModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.27.2 添加进度买方重要事项告知书
- (void)insertProgressBuyerImportantNotificationWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file" : dataArr,
                                        @"saId" : [SISSUserAccount shared].saId,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_BUYER_IMOPRTANT_NOTI parameters:params success:^(id responseObject) {
                
                NSLog(@"4.27.2 添加进度买方重要事项告知书: responseObject-->%@",responseObject);
                
                if ([responseObject[@"code"] integerValue] != 200) {
                    
                    NSLog(@"%@",responseObject[@"data"]);
                }
                if (successBlock) {
                    successBlock(responseObject);
                }
                
            } failure:^(NSError *error) {
                
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.27.3 更新进度买方重要事项告知书 PUT请求
- (void)updateProgressBuyerImportantNotificationWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSArray *dataArr = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"file" : dataArr,
                                            @"saId" : [SISSUserAccount shared].saId,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_BUYER_IMOPRTANT_NOTI parameters:params success:^(id responseObject) {
                    
                    NSLog(@"4.27.3 更新进度买方重要事项告知书 PUT请求: responseObject-->%@",responseObject);
                    
                    if ([responseObject[@"code"] integerValue] != 200) {
                        
                        NSLog(@"%@",responseObject[@"data"]);
                    }
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                    
                } failure:^(NSError *error) {
                    
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_BUYER_IMOPRTANT_NOTI parameters:params success:^(id responseObject) {
            
            NSLog(@"4.27.3 更新进度买方重要事项告知书 PUT请求: responseObject-->%@",responseObject);
            
            if ([responseObject[@"code"] integerValue] != 200) {
                
                NSLog(@"%@",responseObject[@"data"]);
            }
            if (successBlock) {
                successBlock(responseObject);
            }
            
        } failure:^(NSError *error) {
            
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.28.1 获取进度卖方重要事项告知书 GET请求
- (void)requestProgressSellerImportantNotiInfoWithAhbpId:(NSString *)ahbpId success:(void (^)(SISSSellerImportantNotiModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahbpId" : ahbpId
                                 };
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_SELLER_IMOPRTANT_NOTI parameters:parameters success:^(id responseObject) {
        NSLog(@"4.28.1 获取进度卖方重要事项告知书 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSSellerImportantNotiModel *model = [SISSSellerImportantNotiModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.28.2 添加进度卖方重要事项告知书
- (void)insertProgressSellerImportantNotificationWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSMutableArray *dataArrM = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file" : dataArrM,
                                        @"saId" : [SISSUserAccount shared].saId,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_SELLER_IMOPRTANT_NOTI parameters:params success:^(id responseObject) {
                
                NSLog(@"4.28.2 添加进度卖方重要事项告知书: responseObject-->%@",responseObject);
                
                if ([responseObject[@"code"] integerValue] != 200) {
                    
                    NSLog(@"%@",responseObject[@"data"]);
                }
                if (successBlock) {
                    successBlock(responseObject);
                }
                
            } failure:^(NSError *error) {
                
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.28.3 更新进度卖方重要事项告知书 PUT请求
- (void)updateProgressSellerImportantNotificationWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSMutableArray *dataArrM = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"file" : dataArrM,
                                            @"saId" : [SISSUserAccount shared].saId,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_SELLER_IMOPRTANT_NOTI parameters:params success:^(id responseObject) {
                    
                    NSLog(@"4.28.3 更新进度卖方重要事项告知书 PUT请求: responseObject-->%@",responseObject);
                    
                    if ([responseObject[@"code"] integerValue] != 200) {
                        
                        NSLog(@"%@",responseObject[@"data"]);
                    }
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                    
                } failure:^(NSError *error) {
                    
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_SELLER_IMOPRTANT_NOTI parameters:params success:^(id responseObject) {
            
            NSLog(@"4.28.3 更新进度卖方重要事项告知书 PUT请求: responseObject-->%@",responseObject);
            
            if ([responseObject[@"code"] integerValue] != 200) {
                
                NSLog(@"%@",responseObject[@"data"]);
            }
            if (successBlock) {
                successBlock(responseObject);
            }
            
        } failure:^(NSError *error) {
            
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

//  4.34.1 获取居间合同 GET请求
- (void)requestIntermediaryContractWithAhbpId:(NSString *)ahbpId adbpId:(NSString *)adbpId demandType:(NSInteger)demandType houseType:(NSInteger)houseType success:(void (^)(SISSIntermediaryContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                @"ahbpId": ahbpId,
                                @"adbpId": adbpId,
                                @"demand_type": @(demandType),
                                @"house_type": @(houseType)
                                };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_INTERMEDIARY_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.34.1 获取居间合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSIntermediaryContractModel *model = [SISSIntermediaryContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.34.2 添加居间合同 (图文上传)
- (void)insertIntermediaryContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSMutableArray *dataArrM = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArrM,
                                        @"saId" : [SISSUserAccount shared].saId,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_INTERMEDIARY_CONTRACTT parameters:params success:^(id responseObject) {
                NSLog(@"4.34.2 添加居间合同 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.34.3 更新居居间合同 (图文上传) PUT请求
- (void)updateIntermediaryContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSMutableArray *dataArrM = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"file":dataArrM,
                                            @"saId" : [SISSUserAccount shared].saId,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_INTERMEDIARY_CONTRACTT parameters:params success:^(id responseObject) {
                    NSLog(@"4.34.3 更新居居间合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_INTERMEDIARY_CONTRACTT parameters:params success:^(id responseObject) {
            NSLog(@"4.34.3 更新居居间合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.1.25.1  录入二手房买卖合同
- (void)insertBusinessContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"saId" : [SISSUserAccount shared].saId,
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_BUSINESS_CONTRACT parameters:params success:^(id responseObject) {
                NSLog(@"4.1.25.1 录入二手房买卖合同: responseObject-->%@",responseObject);
                
                if ([responseObject[@"code"] integerValue] != 200) {
                    
                    NSLog(@"%@",responseObject[@"data"]);
                }
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}


// 4.1.25.2 获取买卖合同 GET请求
- (void)requestBusinesscontractWithAhbpId:(NSString *)ahbpId adbpId:(NSString *)adbpId success:(void (^)(SISSIntermediaryContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    NSDictionary *parameters = @{
                                 @"ahbpId":ahbpId,
                                 @"adbpId":adbpId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_BUSINESS_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.1.25.2 获取买卖合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        NSDictionary *dataDict = responseObject[@"data"];
        SISSIntermediaryContractModel *model = [SISSIntermediaryContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.1.25.3 更新买卖合同 PUT请求
- (void)updateBusinessContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSArray *dataArr = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"saId" : [SISSUserAccount shared].saId,
                                            @"file":dataArr,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_BUSINESS_CONTRACT parameters:params success:^(id responseObject) {
                    NSLog(@"4.1.25.3 更新买卖合同 PUT请求: responseObject-->%@",responseObject);
                    
                    if ([responseObject[@"code"] integerValue] != 200) {
                        
                        NSLog(@"%@",responseObject[@"data"]);
                    }
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_BUSINESS_CONTRACT parameters:params success:^(id responseObject) {
            NSLog(@"4.1.25.3 更新买卖合同 PUT请求: responseObject-->%@",responseObject);
            
            if ([responseObject[@"code"] integerValue] != 200) {
                
                NSLog(@"%@",responseObject[@"data"]);
            }
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.35.1 新增流程节点 (可图文上传)
- (void)insertAdditionalNodeWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSArray *dataArr = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"saId" : [SISSUserAccount shared].saId,
                                            @"file":dataArr,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_ADDITIONAL_NODE parameters:params success:^(id responseObject) {
                    NSLog(@"4.35.1 新增流程节点 (图文上传): responseObject-->%@",responseObject);
                    
                    if ([responseObject[@"code"] integerValue] != 200) {
                        
                        NSLog(@"%@",responseObject[@"data"]);
                    }
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    @"file": @[],
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_ADDITIONAL_NODE parameters:params success:^(id responseObject) {
            NSLog(@"4.35.1 新增流程节点 (没有图片): responseObject-->%@",responseObject);
            
            if ([responseObject[@"code"] integerValue] != 200) {
                
                NSLog(@"%@",responseObject[@"data"]);
            }
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.35.2 获取新增的流程节点 GET请求
- (void)requestAdditionalNodeWithAhbpId:(NSString *)ahbpId adbpId:(NSString *)adbpId success:(void (^)(SISSAdditionalNodeModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahbpId":ahbpId,
                                 @"adbpId":adbpId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_ADDITIONAL_NODE parameters:parameters success:^(id responseObject) {
        NSLog(@"4.35.2 获取新增的流程节点 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        NSDictionary *dataDict = responseObject[@"data"];
        SISSAdditionalNodeModel *model = [SISSAdditionalNodeModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.36.1 获取核验状态 GET请求
- (void)requestVerifyInfoWithAhbpId:(NSString *)ahbpId adbpId:(NSString *)adbpId success:(void (^)(SISSContractVerifyInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahbpId":ahbpId,
                                 @"adbpId":adbpId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_CONTRACT_VERIFY parameters:parameters success:^(id responseObject) {
        NSLog(@"4.36.1 获取核验状态 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        NSDictionary *dataDict = responseObject[@"data"];
        SISSContractVerifyInfoModel *model = [SISSContractVerifyInfoModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.35.1 同步重要事项告知书 GET请求
- (void)updateProgresImportantNotificationWithAhbpId:(NSString *)ahbpId adbpId:(NSString *)adbpId houseTpye:(NSInteger)houseType demandType:(NSInteger)demandType success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahbpId": ahbpId,
                                 @"adbpId": adbpId,
                                 @"house_type": @(houseType),
                                 @"demand_type": @(demandType)
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_UPDATE_IMPORTANT_NOTI parameters:parameters success:^(id responseObject) {
        NSLog(@"4.35.1 同步重要事项告知书 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock && [responseObject[@"code"] integerValue] == 200) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.39.1 获取居间卖家信息(线下)
- (void)requestIntermediaryContractOfflineSellerInfoWithID:(NSString *)ID success:(void (^)(SISSSellerInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"id":ID
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_INTERMEDIARY_CONTRACT_OFFLINE_SELLER_INFO parameters:parameters success:^(id responseObject) {
        NSLog(@"4.39.1 获取居间卖家信息(线下) GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSSellerInfoModel *sellerInfo = [SISSSellerInfoModel yy_modelWithJSON:dataDict];
        
        if (successBlock) {
            successBlock(sellerInfo);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.39.2 获取居间买家信息(线下)
- (void)requestIntermediaryContractOfflineBuyerInfoWithID:(NSString *)ID success:(void (^)(SISSBuyerInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"id":ID
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_INTERMEDIARY_CONTRACT_OFFLINE_BUYER_INFO parameters:parameters success:^(id responseObject) {
        NSLog(@"4.39.2 获取居间买家信息(线下) GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSBuyerInfoModel *buyerInfo = [SISSBuyerInfoModel yy_modelWithJSON:dataDict];
        
        if (successBlock) {
            successBlock(buyerInfo);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

#pragma mark - 2.0

//  4.43.2 添加租赁带看记录  (图文上传)
- (void)insertLeaseTakeLookRecordWithParameters:(NSDictionary *)parameters imagesArray:(NSArray *)imagesArray successBlock:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [SISSPublicSingleton shared].isHud = NO;
    [kNetworkManager uploadFileListWatermark:imagesArray success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_LEASE_TAKELOOK parameters:params success:^(id responseObject) {
                NSLog(@"4.43.2 添加租赁带看记录 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.43.4 更新租赁进度带看预约记录状态 GET请求
- (void)updateLeaseTakeLookAppointmentStateWithId:(NSString *)ID state:(NSInteger)state success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    NSDictionary *parameters = @{
                                 @"id":ID,
                                 @"state":@(state)
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_UPDATE_LEASE_TAKELOOK_APPOINTMENT_STATE parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.43.4 更新租赁进度带看预约记录状态 GET请求: responseObject-->%@",responseObject);
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock && [responseObject[@"code"] integerValue] == 200) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.43.5 完善租赁进度带看 (图文上传)
- (void)updateLeaseTakeLookRecordWithParameters:(NSDictionary *)parameters imagesArray:(NSArray *)imagesArray successBlock:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [SISSPublicSingleton shared].isHud = NO;
    [kNetworkManager uploadFileListWatermark:imagesArray success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_UPDATE_LEASE_TAKELOOK_RECORD parameters:params success:^(id responseObject) {
                NSLog(@"4.43.5 完善租赁进度带看 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.43.10  删除租赁带看记录 GET请求
- (void)deleteLeaseTakelookWithId:(NSString *)ID success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"id":ID
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_DELETE_LEASE_TAKELOOK parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.43.10  删除租赁带看记录 GET请求: responseObject-->%@",responseObject);
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock && [responseObject[@"code"] integerValue] == 200) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}



// 4.46.1 获取租赁合同 GET请求
- (void)requestTenancyContractWithParameters:(NSDictionary *)parameters success:(void (^)(SISSTenancyContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_LEASE_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.46.1 获取租赁合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSTenancyContractModel *model = [SISSTenancyContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.46.2 添加租赁合同 (图文上传)
- (void)insertLeaseContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSMutableArray *dataArrM = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArrM,
                                        @"saId" : [SISSUserAccount shared].saId,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_LEASE_CONTRACTT parameters:params success:^(id responseObject) {
                NSLog(@"4.46.2 添加租赁合同 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.46.3 更新租赁合 (图文上传) PUT请求
- (void)updateLeaseContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSMutableArray *dataArrM = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"file":dataArrM,
                                            @"saId" : [SISSUserAccount shared].saId,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_LEASE_CONTRACTT parameters:params success:^(id responseObject) {
                    NSLog(@"4.46.3 更新租赁合 (图文上传) PUT请求: responseObject-->%@",responseObject);
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_LEASE_CONTRACTT parameters:params success:^(id responseObject) {
            NSLog(@"4.46.3 更新租赁合 (图文上传) PUT请求: responseObject-->%@",responseObject);
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.46.3 获取求租进度租赁合同 GET请求
- (void)requestTenantProgressTenancyContractWithParameters:(NSDictionary *)parameters success:(void (^)(SISSTenancyContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_TENANT_LEASE_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.46.3 获取求租进度租赁合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSTenancyContractModel *model = [SISSTenancyContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.46.4 添加求租进度租赁合同 (图文上传)
- (void)insertTenantProgressTenancyContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSMutableArray *dataArrM = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArrM,
                                        @"saId" : [SISSUserAccount shared].saId,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_TENANT_LEASE_CONTRACTT parameters:params success:^(id responseObject) {
                NSLog(@"4.46.4 添加求租进度租赁合同 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

@end
